package com.zhsj.OkeHomeConsumption.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.empty.WalletBean;

import java.util.List;

/**
 * Created by zwj on 2018/3/13.
 */

public class ExcessExpectMoneyAdapter extends BaseAdapter {

    private Context context;
    private List<WalletBean> list;
    private LayoutInflater mLayoutInflater;

    public ExcessExpectMoneyAdapter(Context context, List<WalletBean> walletList) {
        this.context = context;
        this.list = walletList;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.item_money_excess, null);
            viewHolder.time_text = (TextView) convertView.findViewById(R.id.time_text);
            viewHolder.busi_money_text = (TextView) convertView.findViewById(R.id.busi_money_text);
            viewHolder.busi_des_text = (TextView) convertView.findViewById(R.id.busi_des_text);
            viewHolder.busi_number_text = (TextView) convertView.findViewById(R.id.busi_number_text);
            viewHolder.design_money_text = (TextView) convertView.findViewById(R.id.design_money_text);
            viewHolder.design_des_text = (TextView) convertView.findViewById(R.id.design_des_text);
            viewHolder.design_number_text = (TextView) convertView.findViewById(R.id.design_number_text);
            viewHolder.home_money_text = (TextView) convertView.findViewById(R.id.home_money_text);
            viewHolder.home_des_text = (TextView) convertView.findViewById(R.id.home_des_text);
            viewHolder.home_number_text = (TextView) convertView.findViewById(R.id.home_number_text);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final WalletBean item = list.get(position);

        if (item != null) {
            viewHolder.time_text.setText(item.getSign());
            viewHolder.busi_money_text.setText(item.getBusiAmount() + "元");
            viewHolder.busi_des_text.setText(item.getDes());
            viewHolder.busi_number_text.setText(item.getBusiNum() + "");

            viewHolder.design_money_text.setText(item.getDesignAmount() + "元");
            viewHolder.design_des_text.setText(item.getDes1());
            viewHolder.design_number_text.setText(item.getDesignNum() + "");

            viewHolder.home_money_text.setText(item.getHomeAmount() + "元");
            viewHolder.home_des_text.setText(item.getDes2());
            viewHolder.home_number_text.setText(item.getHomeNum() + "");
        }
        return convertView;
    }


    class ViewHolder {
        private TextView time_text;
        private TextView busi_money_text;
        private TextView busi_des_text;
        private TextView busi_number_text;
        private TextView design_money_text;
        private TextView design_des_text;
        private TextView design_number_text;
        private TextView home_money_text;
        private TextView home_des_text;
        private TextView home_number_text;
    }
}